package com.shire.shire_interface.service.group.impl;

import com.alibaba.fastjson.JSONObject;
import com.shire.shire_interface.common.utils.StrUtils;
import com.shire.shire_interface.constants.Constants;
import com.shire.shire_interface.constants.WxConstants;
import com.shire.shire_interface.constants.WxErrorCode;
import com.shire.shire_interface.dao.group.VGroupInviteHistoryDao;
import com.shire.shire_interface.dao.group.WxGroupDao;
import com.shire.shire_interface.dao.group.WxGroupInviteHistoryDao;
import com.shire.shire_interface.dao.group.WxGroupMemberDao;
import com.shire.shire_interface.model.command.WxCommand;
import com.shire.shire_interface.model.cs.WxChat;
import com.shire.shire_interface.model.group.*;
import com.shire.shire_interface.model.user.WxAccount;
import com.shire.shire_interface.service.chat.WxChatService;
import com.shire.shire_interface.service.commandcenter.BaseCommandProcessor;
import com.shire.shire_interface.service.commandcenter.WxCommandService;
import com.shire.shire_interface.service.group.WxGroupService;
import com.shire.shire_interface.service.group.WxGroupWaitService;
import com.shire.shire_interface.service.marketing.WxGroupKeywordService;
import com.shire.shire_interface.service.marketing.WxGroupTaskService;
import com.shire.shire_interface.service.welcome.WxWelcomeSettingService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * 作者:  sll
 * 时间:  2019/7/25 15:09
 */
@Service
public class WxGroupServiceImpl implements WxGroupService {
    private static Logger logger = LoggerFactory.getLogger(WxGroupServiceImpl.class);
    @Resource
    private WxGroupDao wxGroupDao;

    @Resource
    private WxGroupWaitService groupWaitService;

    @Resource
    private WxGroupInviteHistoryDao historyDao;

    @Resource
    private VGroupInviteHistoryDao vGroupInviteHistoryDao;

    @Resource
    private WxGroupMemberDao groupMemberDao;

    @Resource
    private WxWelcomeSettingService welcomeSettingService;
    @Resource
    private WxGroupQrcodeService qrcodeService;

    @Resource
    private WxGroupKeywordService groupKeywordService;

    @Resource
    private WxGroupTaskService groupTaskService;

    @Resource
    private WxBlacklistService blacklistService;

    @Resource
    private WxChatService chatService;

    private List<String> blackList;

    @Resource
    private WxCommandService commandService;
    @Resource
    private BaseCommandProcessor commandProcessor;

    @Override
    public List<VGroupInviteHistory> getInviteHistoryDetail(String groupNo, String wxAccount) {
        VGroupInviteHistoryExample example = new VGroupInviteHistoryExample();
        example.createCriteria().andGroupNoEqualTo(groupNo).andWxAccountEqualTo(wxAccount);
        return vGroupInviteHistoryDao.selectByExample(example);
    }

    @Override
    public List<WxGroup> getAllGroups(WxGroupExample example) {
        return wxGroupDao.selectByExample(example);
    }

    @Override
    public Long getGroupCountByCsIdAndAccount(WxGroupExample groupExample) {
        return wxGroupDao.countByExample(groupExample);
    }

    public WxGroup getGroup(Integer csId, String wxAccount, String groupId ){
        WxGroupExample groupExample = new WxGroupExample();
        groupExample.createCriteria().andWxaccountEqualTo(wxAccount).andGroupnoEqualTo(groupId);
        List<WxGroup> groupList = wxGroupDao.selectByExample(groupExample);
        if (groupList.size()>0)
            return groupList.get(0);
        return null;
    }

    public boolean groupExists(String groupNo){
        WxGroupExample groupExample = new WxGroupExample();
        groupExample.createCriteria().andGroupnoEqualTo(groupNo);
        List groupList = wxGroupDao.selectByExample(groupExample);
        return groupList.size() > 0 ;
    }

    public Map<String, WxGroup> getGroupsMap(Integer csId, String account){
        WxGroupExample groupExample = new WxGroupExample();
        groupExample.createCriteria().andWxaccountEqualTo(account);

        List<WxGroup> list = wxGroupDao.selectByExample(groupExample);
        Map<String, WxGroup> map = new HashMap<>();
        for(WxGroup wxGroup : list){
            map.put(wxGroup.getGroupno(), wxGroup);
        }
        return map;
    }

    public void syncGroups(String type, List<Map<String, Object>> reqList, WxAccount account){
        if(this.blackList ==null){
            List<WxBlacklist> list = this.blacklistService.getBlackList();
            this.blackList = new ArrayList<>();
            for (WxBlacklist item : list){
                this.blackList.add(item.getNickname());
            }
        }
        if(type.equalsIgnoreCase("whole")){
            syncGroupsWhole(reqList, account);
        }
        else if(type.equalsIgnoreCase("increment")){
            syncGroupsIncrement(reqList, account, type);
        }
        else if(type.equalsIgnoreCase("update")){
            syncGroupsIncrement(reqList, account, type);
        }
        else if(type.equalsIgnoreCase("remove")){
            syncGroupsRemove(reqList, account);
        }
    }

    @Override
    public List<WxGroup> selectByExample(WxGroupExample wxGroupExample) {
        return wxGroupDao.selectByExample(wxGroupExample);
    }

    @Override
    public WxGroup selectById(Integer id) {
        return wxGroupDao.selectByPrimaryKey(id);
    }

    @Override
    public int deleteByExample(WxGroupExample wxGroupExample) {
        return wxGroupDao.deleteByExample(wxGroupExample);
    }

    @Override
    public WxGroup selectGroupByNoForCs(Integer csId, String wxAccount, String groupNo) {
        WxGroupExample groupExample = new WxGroupExample();
        groupExample.createCriteria().andWxaccountEqualTo(wxAccount).andGroupnoEqualTo(groupNo).andStatusEqualTo(Constants.CommonStatus.ENABLE.getCode());

        List<WxGroup> groupList = wxGroupDao.selectByExample(groupExample);
        if (groupList != null && groupList.size() > 0){
            return  groupList.get(0);
        }
        return null;
    }

    @Override
    public void deteleMember(Integer csId, String wxAccount, String groupNo, String wxid) {
        WxGroupMemberExample example = new WxGroupMemberExample();
        example.createCriteria().andWxaccountEqualTo(wxAccount).andGroupnoEqualTo(groupNo).andWxidEqualTo(wxid);
        List<WxGroupMember> members = groupMemberDao.selectByExample(example);
        for (WxGroupMember member : members) {
            groupMemberDao.deleteByPrimaryKey(member.getId());
        }
    }

    /**
     * 同步群列表，群成员列表
     * @param reqList
     * @param account
     */
    public void syncGroupsWhole(List<Map<String, Object>> reqList , WxAccount account){
        String wxAccount = account.getWxid();
        if(StrUtils.isBlank(wxAccount)) return;
        synchronized (wxAccount.intern()) {
            Map<String, WxGroup> oldMap = getGroupsMap(account.getCsid(),wxAccount);
            for (Map<String, Object> reqMap : reqList) {
                String userName = (String) reqMap.get("groupUserName");
                String groupName = (String) reqMap.get("groupName");
                String avatar = (String)reqMap.get("avatar");
                String owner = (String) reqMap.get("admin");
                Long groupVersion = Long.parseLong((String)reqMap.get("groupVersion"));
                Integer isAdmin = account.getWxid().equals(reqMap.get("admin")) ? 1 : 2;
                String ownerWxId = StrUtils.getNullStr(reqMap.get("ownerWxId"));
                Boolean isChatroomNeedAccessVerify = StrUtils.getBoolean(String.valueOf(reqMap.get("isChatroomNeedAccessVerify")), false);
                if (reqMap.containsKey("qrcode")){
                    saveGroupQrCode(account.getWxid(),userName, (String) reqMap.get("qrcode"));
                }
                WxGroup group = oldMap.get(userName);
                if (group == null) {
                    group = new WxGroup();
                    group.setGroupno(userName);
                    group.setWxaccount(wxAccount);
                    group.setFriendid(0);
                    group.setQuitstatus(-101);
                    group.setCsid(account.getCsid());
                    group.setCreatetime(new Date());
                    group.setAvatar(avatar);

                    group.setStatus(Constants.CommonStatus.ENABLE.ordinal());
                    group.setIsfirst(isAdmin);
                    // 根据wait回填信息
                    WxGroupWait wxGroupWait = groupWaitService.getGroupWait(account.getCsid(),wxAccount, userName);
                    if(wxGroupWait!=null){
                        group.setFriendid(wxGroupWait.getFriendid());
                        group.setFriendwxid(wxGroupWait.getFriendwxid());
                        group.setCsid(wxGroupWait.getCsid());
                        group.setJointime(wxGroupWait.getJointime());
                    }
                } else {
                    oldMap.remove(userName);
                }
                group.setGroupname(groupName);
                group.setOwner(owner);
                group.setIsfirst(isAdmin);
                group.setNeedverify(isChatroomNeedAccessVerify ? Constants.YesNo.YES.getCode():Constants.YesNo.NO.getCode());
//                if(wxAccountService.isBaseGroup(groupName)){
//                    group.setIsBase(Constants.YesNo.YES.getCode());
//                }
                group.setPersonnum(StrUtils.getIntValue(String.valueOf(reqMap.get("memberCount")), 0));

                //版本号发生变化，就需要新，不然就跳过
                boolean isDirty = true;//group.getGroupversion() == null || !group.getGroupversion().equals(groupVersion);
                group.setGroupversion(groupVersion);

                if(group.getStatus()!=null && group.getStatus()==Constants.CommonStatus.ENABLE.getCode()) {
                    group.setUpdatetime(new Date());
                }
                boolean isNewGroup =false;
                group.setStatus(Constants.CommonStatus.ENABLE.getCode());
                if (group.getId() == null) {
//                    saveObject(group);
                    wxGroupDao.insertSelective(group);
                    isNewGroup = true;
//                    addGroupLog(group, Constants.CommonStatus.ENABLE.getCode());
                } else {
                    if (isDirty) {
                        wxGroupDao.updateByPrimaryKey(group);
                    }
                }
                processNewMembers(account, wxAccount, reqMap, ownerWxId, group, isDirty);
            }
            // 删除未同步的群
            for (Map.Entry<String, WxGroup> entry : oldMap.entrySet()) {
                WxGroup wxGroup = entry.getValue();
                deleteGroup(wxGroup);
                deleteMembers(account,wxGroup.getGroupno());
            }
        }
    }

    private void processNewMembers(WxAccount account, String wxAccount, Map<String, Object> reqMap, String ownerWxId, WxGroup group, boolean isDirty) {
        if (isDirty) {
            // 设置成员列表
            List<String> blockMembers = new ArrayList<>();
            List<WxGroupMember> newMembers = setGroupMembers(group, (List<Map<String, Object>>) reqMap.get("members"), ownerWxId,blockMembers);
            if (newMembers.size() > 0) {
                welcomeSettingService.checkWelcomResponse(account, group, newMembers);
                updateKeywordJoinResult(wxAccount, group, newMembers);
            }
            if (blockMembers.size()>0){
                for (int i = 0; i< blockMembers.size();i++)
                    this.removeMember(group.getGroupno(),blockMembers.get(i),account);
            }
        }
    }

    private void deleteMembers(WxAccount account, String groupNo){
        WxGroupMemberExample example = new WxGroupMemberExample();
        example.createCriteria().andWxaccountEqualTo(account.getWxid()).andGroupnoEqualTo(groupNo);

        WxGroupMember member = new WxGroupMember();
        member.setStatus(Constants.CommonStatus.DELETE.getCode());
        groupMemberDao.updateByExampleSelective(member, example);
    }

    public void syncGroupsIncrement(List<Map<String, Object>> reqList, WxAccount account, String type){
        String wxAccount = account.getWxid();
        if(StrUtils.isBlank(wxAccount)) return;
        synchronized (wxAccount.intern()) {
            for (Map<String, Object> reqMap : reqList) {
                String userName = (String) reqMap.get("groupUserName");
                String groupName = (String) reqMap.get("groupName");
                String ownerWxId = StrUtils.getNullStr(reqMap.get("ownerWxId"));
                String avatar = (String)reqMap.get("avatar");
                String owner = (String) reqMap.get("admin");
                Long groupVersion = Long.parseLong((String)reqMap.get("groupVersion"));
                Integer isAdmin = account.getWxid().equals(reqMap.get("admin")) ? 1 : 2;
                Boolean isChatroomNeedAccessVerify = StrUtils.getBoolean(String.valueOf(reqMap.get("isChatroomNeedAccessVerify")), false);
                if (reqMap.containsKey("qrcode")){
                    saveGroupQrCode(account.getWxid(),userName, (String) reqMap.get("qrcode"));
                }
                WxGroup group = getGroup(account.getCsid(),wxAccount, userName);
                if (group == null) {
                    group = new WxGroup();
                    group.setGroupno(userName);
                    group.setWxaccount(wxAccount);
                    group.setFriendid(0);
                    group.setQuitstatus(-101);
                    group.setCreatetime(new Date());
                }
                group.setNeedverify(isChatroomNeedAccessVerify ? Constants.YesNo.YES.getCode():Constants.YesNo.NO.getCode());
                if(type.equals("increment")) {
                    // 根据wait回填信息
                    WxGroupWait wxGroupWait = groupWaitService.getGroupWait(account.getCsid(),wxAccount, userName);
                    if(wxGroupWait!=null){
                        group.setFriendid(wxGroupWait.getFriendid());
                        group.setFriendwxid(wxGroupWait.getFriendwxid());
                        group.setJointime(wxGroupWait.getJointime());
                        group.setCsid(wxGroupWait.getCsid());
                    }
                    group.setStatus(Constants.CommonStatus.ENABLE.ordinal());
                }
                group.setGroupname(groupName);
                group.setAvatar(avatar);
                group.setOwner(owner);
                group.setCsid(account.getCsid());
                //                if(wxAccountService.isBaseGroup(groupName)){
//                    group.setIsBase(Constants.YesNo.YES.getCode());
//                }
                group.setIsfirst(isAdmin);
                group.setPersonnum(StrUtils.getIntValue(String.valueOf(reqMap.get("memberCount")), 0));

                boolean isDirty = true;//group.getGroupversion() == null || !group.getGroupversion().equals(groupVersion);
                group.setGroupversion(groupVersion);

                if(group.getStatus()!=null && group.getStatus()==Constants.CommonStatus.ENABLE.getCode()) {
                    group.setUpdatetime(new Date());
                }
                boolean isNewGroup =false;
                if (group.getId() == null) {
                    if(groupName==null && group.getPersonnum()==0){
                        continue;
                    }
                    wxGroupDao.insertSelective(group);
                    isNewGroup = true;
//                    addGroupLog(group, Constants.CommonStatus.ENABLE.getCode());
                } else {
                    if (isDirty)
                        wxGroupDao.updateByPrimaryKey(group);
                }
                processNewMembers(account, wxAccount, reqMap, ownerWxId, group, isDirty);
            }
        }
    }

    private void updateKeywordJoinResult(String wxAccount, WxGroup group, List<WxGroupMember> newMembers) {
        List<String> wxIdlist = new ArrayList<>();
        for (WxGroupMember newMember : newMembers) {
            wxIdlist.add(newMember.getWxid());
        }
        groupKeywordService.updateByAfterJoin(wxAccount, group.getGroupno(), wxIdlist);
    }

    private void saveGroupQrCode(String wxAccount, String groupNo, String qrcode){
        WxGroupQrcode groupQrcode = qrcodeService.getGroupQrcode(wxAccount,groupNo);
        if (groupQrcode == null){
            groupQrcode = new WxGroupQrcode();
            groupQrcode.setGroupno(groupNo);
            groupQrcode.setWxaccount(wxAccount);
            groupQrcode.setQrcode(qrcode);
        }else {
            groupQrcode.setQrcode(qrcode);
        }
        qrcodeService.saveGroupQrcode(groupQrcode);
    }

    public void syncGroupsRemove(List<Map<String, Object>> reqList, WxAccount account){
        synchronized (account.getWxid().intern()) {
            for (Map<String, Object> reqMap : reqList) {
                String groupUserName = (String) reqMap.get("groupUserName");
                if (StrUtils.isBlank(groupUserName)) continue;
                WxGroup wxGroup = getGroup(account.getCsid(), account.getWxid(), groupUserName);
                if (wxGroup != null) {
                    deleteGroup(wxGroup);
                }
            }
        }
    }

    private void deleteGroup(WxGroup wxGroup){
        wxGroup.setStatus(Constants.CommonStatus.DELETE.ordinal());
        wxGroup.setUpdatetime(new Date());
        wxGroupDao.updateByPrimaryKeySelective(wxGroup);
//        addGroupLog(wxGroup, Constants.CommonStatus.DELETE.ordinal());
    }

    /**
     * 获取群成员map
     * @param groupNo
     * @return
     */
    private Map<String, WxGroupMember> getGroupMembers(String groupNo, String wxAccount, Integer csId){
        if(groupNo==null) return new HashMap<>();
        Map<String, WxGroupMember> membersMap = new HashMap<>();


        WxGroupMemberExample memberExample = new WxGroupMemberExample();
        memberExample.createCriteria().andGroupnoEqualTo(groupNo).andWxaccountEqualTo(wxAccount);
        List<WxGroupMember> members = groupMemberDao.selectByExample(memberExample);
        for(WxGroupMember member : members){
            membersMap.put(member.getWxid(), member);
        }
        return membersMap;
    }

    private Map<String, WxGroupInviteHistory> getInviteHistory(String groupNo, String wxAccount){
        Map<String ,WxGroupInviteHistory> historyMap = new HashMap<>();
        WxGroupInviteHistoryExample example = new WxGroupInviteHistoryExample();
        example.createCriteria().andGroupNoEqualTo(groupNo).andWxAccountEqualTo(wxAccount);
        List<WxGroupInviteHistory> list = historyDao.selectByExample(example);

        for(WxGroupInviteHistory item : list){
            historyMap.put(item.getInviteeWxId(),item);
        }
        return historyMap;
    }


    /**
     * 设置群成员列表
     * @param wxGroup
     * @param members
     * @param ownerWxId
     */
    private List<WxGroupMember> setGroupMembers(WxGroup wxGroup, List<Map<String, Object>> members, String ownerWxId, List<String> blockedMember){
        List<WxGroupMember> newMembers = new ArrayList<>();
        List<WxGroupMember> insertMembers = new ArrayList<>();
        List<WxGroupMember> updateMembers = new ArrayList<>();
        if(wxGroup==null || members==null || members.isEmpty()){
            return newMembers;
        }
        Date startDate = new Date();

        WxGroupMemberExample memberExample = new WxGroupMemberExample();
        memberExample.createCriteria().andGroupidEqualTo(wxGroup.getId());

        int insertCount = 0;

        logger.info("member size ++++++" + members.size());

        Map<String, WxGroupMember> oldMap = getGroupMembers(wxGroup.getGroupno(),wxGroup.getWxaccount(),wxGroup.getCsid());
        Map<String, WxGroupInviteHistory> historyMap = getInviteHistory(wxGroup.getGroupno(), wxGroup.getWxaccount());
        List<WxGroupInviteHistory> historyList = new ArrayList<>();
        for(Map<String, Object> memberMap : members){
            if(memberMap==null || !memberMap.containsKey("wxId"))
                continue;
            String memberWxId = (String)memberMap.get("wxId");
            if(StrUtils.isBlank(memberWxId)){
                continue;
            }
            WxGroupMember wxGroupMember = oldMap.get(memberWxId);
            if(wxGroupMember==null){
                wxGroupMember = new WxGroupMember();
                wxGroupMember.setGroupid(wxGroup.getId());
                wxGroupMember.setWxid(memberWxId);
                wxGroupMember.setCreatetime(new Date());
            }
            else {
                oldMap.remove(memberWxId);
            }
            wxGroupMember.setGroupno(wxGroup.getGroupno());
            wxGroupMember.setAlias((String)memberMap.get("alias"));
            wxGroupMember.setInviter((String)memberMap.get("inviter"));
            wxGroupMember.setNick((String)memberMap.get("nick"));
            wxGroupMember.setGroupnick((String)memberMap.get("displayName"));
            wxGroupMember.setIsowner(ownerWxId.equals(memberWxId) ? Constants.YesNo.YES.ordinal(): Constants.YesNo.NO.ordinal());
            wxGroupMember.setAvatar((String)memberMap.get("avatar"));
            wxGroupMember.setIsmycontact((int)memberMap.get("isMyContact"));
            wxGroupMember.setArea((String)memberMap.get("area"));
            wxGroupMember.setSignature((String)memberMap.get("signature"));
            wxGroupMember.setSex(StrUtils.getIntValue(String.valueOf(memberMap.get("sex")), null));
            wxGroupMember.setCsid(wxGroup.getCsid());
            wxGroupMember.setWxaccount(wxGroup.getWxaccount());

            if (!historyMap.containsKey(wxGroupMember.getWxid()) && StringUtils.isNotEmpty(wxGroupMember.getInviter())){
                WxGroupInviteHistory history = new WxGroupInviteHistory();
                history.setGroupNo(wxGroup.getGroupno());
                history.setInviteeWxId(wxGroupMember.getWxid());
                history.setInviterWxId(wxGroupMember.getInviter());
                history.setWxAccount(wxGroup.getWxaccount());
                history.setCreateTime(new Date());
                historyList.add(history);
            }


            if(wxGroupMember.getId()==null){
//                groupMemberDao.insertSelective(wxGroupMember);
                newMembers.add(wxGroupMember);
                wxGroupMember.setStatus(0);
                insertMembers.add(wxGroupMember);
                groupTaskService.updateForNewMember(wxGroup.getGroupno(), wxGroupMember.getWxid());

            }
            else {
//                if (wxGroupMember.getStatus() !=null && wxGroupMember.getStatus() == 1){
//                    newMembers.add(wxGroupMember);
//                }
                wxGroupMember.setStatus(0);
//                groupMemberDao.updateByPrimaryKeySelective(wxGroupMember);
                updateMembers.add(wxGroupMember);
            }

            if (this.blackList.contains(wxGroupMember.getWxid())||this.blackList.contains(wxGroupMember.getNick())){
                blockedMember.add(wxGroupMember.getWxid());
            }

        }
        if (insertMembers.size()>0)
            groupMemberDao.batchInsertByPrimaryKeySelective(insertMembers);
        if (updateMembers.size()>0)
            groupMemberDao.batchUpdateByPrimaryKeySelective(updateMembers);
        Date endDate = new Date();
        logger.info("+++++++ use time :"+(endDate.getTime() - startDate.getTime()));

        // 删除未同步成员
        if (members.size() == 1) { //如果只有一个就不删除其它人
            for (Map.Entry<String, WxGroupMember> entry : oldMap.entrySet()) {
                WxGroupMember wxGroupMember = entry.getValue();
                if (wxGroupMember.getStatus() == null || wxGroupMember.getStatus() == 0) {
                    wxGroupMember.setStatus(1);
                    groupMemberDao.updateByPrimaryKeySelective(wxGroupMember);

                    JSONObject msg = new JSONObject();
                    msg.put("msgtype",1);
                    msg.put("content", wxGroupMember.getNick()+"("+wxGroupMember.getAlias()+")"+"退出了群聊");


                    WxChat chat = new WxChat();
                    chat.setWxaccount(wxGroup.getWxaccount());
                    chat.setMsgid(String.valueOf((new Date()).getTime()));
                    chat.setFriendwxid(wxGroup.getGroupno());
                    chat.setFriendNick(wxGroup.getGroupname());
                    chat.setAvatar(wxGroup.getAvatar());

                    chat.setChatfrom(WxConstants.ChatFrom.SYSTEM.getCode());
                    chat.setContent(msg.toJSONString());
                    chat.setMsgtype(WxConstants.MessageType.TEXT.getCode());
                    chat.setSendstatus(WxErrorCode.INIT_VALUE);
                    chat.setReadstatus(Constants.YesNo.YES.ordinal());
                    chat.setFromplat(0);
                    chat.setShowstatus(Constants.YesNo.YES.getCode());
                    chat.setCreatetime(new Date());
                    chat.setReadtime(new Date());
                    chatService.saveChat(chat);
                    chatService.sendToKf(chat, wxGroup);
                }
//            groupMemberDao.deleteByPrimaryKey(wxGroupMember.getId());
            }
        }
        if (historyList.size()>0)
            historyDao.batchInsertByPrimaryKeySelective(historyList);

        return newMembers;
    }
    private void removeMember(String groupNo, String memberWxId, WxAccount account){
        JSONObject cmdJson = new JSONObject();
        cmdJson.put("groupWxId",groupNo);
        cmdJson.put("userWxIds",memberWxId);
        WxCommand wxCommand = commandService.generateCmdObject(account.getCsid(),account.getId(),cmdJson.toJSONString(),WxConstants.CmdTaskType.UNKNOWN, -1, WxConstants.CmdType.CRK_REMOVE_GROUP_USERS_D,WxConstants.CmdPriority.UNKNOWN);
        commandProcessor.addCommand(account.getCsid(),account.getId(),wxCommand);
//        this.deteleMember(account.getCsid(),account.getWxid(),groupNo,memberWxId);
    }
}
